$sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
"LENGTH(cur_text) DESC LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$sk = $wgUser->getSkin();
. " AND d.cur_namespace=0"
. " LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$sk = $wgUser->getSkin();
$sql = "SELECT l_from,l_to,cb.cur_text AS rt,cb.cur_title AS ti FROM links,cur AS ca, cur AS cb WHERE ca.cur_is_redirect=1 AND cb.cur_is_redirect=1 AND l_to=cb.cur_id AND l_from=ca.cur_title AND ca.cur_namespace=0 LIMIT {$offset}, {$limit}" ;
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$top = getMaintenancePageBacklink();
$top .= "<p>".wfMsg("doubleredirectstext")."</p><br>\n";
$sql = "SELECT bl_to,cur_title FROM brokenlinks,cur WHERE cur_is_redirect=1 AND cur_namespace=0 AND bl_from=cur_id LIMIT {$offset}, {$limit}" ;
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$top = getMaintenancePageBacklink();
$top .= "<p>".wfMsg("brokenredirectstext")."</p><br>\n";
$sql = "SELECT cur_title FROM cur,links WHERE cur_is_redirect=0 AND cur_namespace=0 AND l_from=cur_title AND l_to=cur_id LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$top = getMaintenancePageBacklink();
$top .= "<p>".wfMsg("selflinkstext")."</p><br>\n";
# Load list from database
$sql = "SELECT cur_text FROM cur WHERE cur_title='{$mss}' AND cur_namespace=4" ;
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$obj = wfFetchObject ( $res ) ;
$l = $obj->cur_text ;
$l = explode ( "\n" , $l ) ;
$x = preg_replace( '/^(\S+).*$/', '$1', $x );
#$sql = "SELECT DISTINCT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND (MATCH(cur_ind_text) AGAINST ('" . wfStrencode( $wgLang->stripForSearch( $x ) ) . "'))" ;
$sql = "SELECT DISTINCT cur_title FROM cur,searchindex WHERE cur_id=si_page AND cur_namespace=0 AND cur_is_redirect=0 AND (MATCH(si_text) AGAINST ('" . wfStrencode( $wgLang->stripForSearch( $x ) ) . "'))" ;
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
while ( $obj = wfFetchObject ( $res ) ) {
if ( $cnt >= $offset AND $cnt < $offset+$limit ) {
if ( $y != "" ) {
$sql = "SELECT cur_title FROM cur WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$mll = wfMsg("missinglanguagelinkstext");
$sql = "SELECT cur_is_redirect,cur_text FROM cur " .
"WHERE cur_id={$this->newid}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$obj = wfFetchObject( $res );
if ( 0 == $obj->cur_is_redirect ) { return false; }
}
$sql = "SELECT old_id FROM old WHERE old_namespace={$this->nns} " .
"AND old_title='{$this->ndt}'";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
if ( 0 != wfNumRows( $res ) ) { return false; }
return true;
$sql = "UPDATE cur SET cur_touched='{$now}'," .
"cur_namespace={$this->nns},cur_title='{$this->ndt}' " .
"WHERE cur_id={$this->oldid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE cur SET cur_touched='{$now}'," .
"cur_namespace={$this->ons},cur_title='{$this->odt}'," .
"',cur_minor_edit=0,cur_counter=0,cur_restrictions=''," .
"cur_user_text='" . wfStrencode( $wgUser->getName() ) . "'," .
"cur_is_redirect=1,cur_is_new=0 WHERE cur_id={$this->newid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE old SET " .
"old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " .
"old_namespace={$this->ons} AND old_title='{$this->odt}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE recentchanges SET ".
"rc_namespace={$this->nns}, rc_title='{$this->ndt}' WHERE ".
"rc_cur_id={$this->oldid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "INSERT INTO recentchanges (rc_namespace,rc_title,
rc_comment,rc_user,rc_user_text,rc_timestamp,
"'{$mt} \\\"{$this->nft}\\\"','" .
$wgUser->getID() . "','" . wfStrencode( $wgUser->getName() ) .
"','{$now}','{$now}',{$this->newid},1)";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# The only link from here should be the old redirect
$sql = "DELETE FROM links WHERE l_from='{$this->nft}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# Swap links. Using MAXINT as a temp; if there's ever an article
# with id 4294967295, this will fail, but I think that's pretty safe
$sql = "UPDATE links SET l_to=4294967295 WHERE l_to={$this->oldid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE links SET l_to={$this->oldid} WHERE l_to={$this->newid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE links SET l_to={$this->newid} WHERE l_to=4294967295";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# Note: the insert below must be after the updates above!
$sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
}
# Move page to non-existing title.
$sql = "UPDATE cur SET cur_touched='{$now}'," .
"cur_namespace={$this->nns},cur_title='{$this->ndt}' " .
"WHERE cur_id={$this->oldid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$common = "{$this->ons},'{$this->odt}'," .
"'{$mt} \\\"{$this->nft}\\\"','" .
"cur_comment,cur_user,cur_user_text,cur_timestamp,inverse_timestamp," .
"cur_touched,cur_text,cur_is_redirect,cur_is_new) " .
"VALUES ({$common},'{$won}','{$now}','#REDIRECT [[{$this->nft}]]\n',1,1)";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$this->newid = wfInsertId();
$sql = "UPDATE old SET " .
"old_namespace={$this->nns},old_title='{$this->ndt}' WHERE " .
"old_namespace={$this->ons} AND old_title='{$this->odt}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE recentchanges SET ".
"rc_namespace={$this->nns}, rc_title='{$this->ndt}' WHERE ".
"rc_namespace={$this->ons} AND rc_title='{$this->odt}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "INSERT INTO recentchanges (rc_namespace,rc_title,
rc_comment,rc_user,rc_user_text,rc_timestamp,
rc_cur_time,rc_cur_id,rc_new)
VALUES ({$common},'{$now}',{$this->newid},1)";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE links SET l_from='{$this->nft}' WHERE l_from='{$this->oft}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "UPDATE links SET l_to={$this->newid} WHERE l_to={$this->oldid}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$sql = "INSERT INTO links (l_from,l_to) VALUES ('{$this->oft}',{$this->oldid})";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# Non-existent target may have had broken links to it; these must
# now be removed and made into good links.
$update->fixBrokenLinks();
$sql = "UPDATE imagelinks SET il_from='{$this->nft}' WHERE il_from='{$this->oft}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
}
function updateWatchlists()
$sql = "SELECT wl_user FROM watchlist
WHERE wl_namespace={$oldnamespace} AND wl_title='{$oldtitle}'";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
if( $s = wfFetchObject( $res ) ) {
$sql = "REPLACE INTO watchlist (wl_user,wl_namespace,wl_title)
VALUES ({$s->wl_user},{$newnamespace},'{$newtitle}')";
while( $s = wfFetchObject( $res ) ) {
$sql .= ",({$s->wl_user},{$newnamespace},'{$newtitle}')";
}
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
}
}
"rc_timestamp AS cur_timestamp,length(cur_text) as cur_length FROM recentchanges,cur " .
"WHERE rc_cur_id=cur_id AND rc_new=1 AND rc_namespace=0 AND cur_is_redirect=0 " .
"ORDER BY rc_timestamp DESC LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$top = wfShowingResults( $offset, $limit );
$wgOut->addHTML( "<p>{$top}\n" );
$sql = "SELECT DISTINCT cur_title, cur_counter FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
"cur_counter DESC LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$sk = $wgUser->getSkin();
AND cur_random>$randstr
ORDER BY cur_random
LIMIT 1";
- $res = wfQuery( $sqlget, $fname );
+ $res = wfQuery( $sqlget, DB_READ, $fname );
if( $s = wfFetchObject( $res ) ) {
$rt = wfUrlEncode( $s->cur_title );
} else {
}
$sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$s = wfFetchObject( $res );
$wgOut->checkLastModified( $s->lastmod );
# The next few lines can probably be commented out now that wfMsg can get text from the DB
$sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
$rctext = $s->cur_text;
}
($uid ? "LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
"WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
"ORDER BY rc_timestamp DESC LIMIT {$limit}";
- $res = wfQuery( $sql2, $fname );
+ $res = wfQuery( $sql2, DB_READ, $fname );
if(isset($from)) {
$note = wfMsg( "rcnotefrom", $limit,
"WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
"ORDER BY inverse_timestamp LIMIT {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$note = wfMsg( "rcnote", $limit, $days );
$wgOut->addHTML( "<hr>\n{$note}\n<br>" );
$sql = "SELECT cur_title, LENGTH(cur_text) AS len FROM cur " .
"WHERE cur_namespace=0 AND cur_is_redirect=0 ORDER BY " .
"LENGTH(cur_text) LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$top = wfShowingResults( $offset, $limit );
$wgOut->addHTML( "<p>{$top}\n" );
$wgOut->addHTML( "<h2>" . wfMsg( "sitestats" ) . "</h2>\n" );
$sql = "SELECT COUNT(cur_id) AS total FROM cur";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$row = wfFetchObject( $res );
$total = $row->total;
$sql = "SELECT ss_total_views, ss_total_edits, ss_good_articles " .
"FROM site_stats WHERE ss_row_id=1";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$row = wfFetchObject( $res );
$views = $row->ss_total_views;
$edits = $row->ss_total_edits;
$wgOut->addHTML( "<h2>" . wfMsg( "userstats" ) . "</h2>\n" );
$sql = "SELECT COUNT(user_id) AS total FROM user";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$row = wfFetchObject( $res );
$total = $row->total;
$sql = "SELECT COUNT(user_id) AS total FROM user " .
"WHERE user_rights LIKE '%sysop%'";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$row = wfFetchObject( $res );
$admins = $row->total;
# List undeletable articles
$sql = "SELECT ar_namespace,ar_title, COUNT(*) AS count FROM archive GROUP BY ar_namespace,ar_title ORDER BY ar_title";
- $res = wfQuery( $sql );
+ $res = wfQuery( $sql, DB_READ );
$wgOut->setPagetitle( wfMsg( "undeletepage" ) );
$wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
$sql = "SELECT ar_text FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\" AND ar_timestamp={$timestamp}";
- $ret = wfQuery( $sql );
+ $ret = wfQuery( $sql, DB_READ );
$row = wfFetchObject( $ret );
$wgOut->setPagetitle( wfMsg( "undeletepage" ) );
$sql = "SELECT ar_minor_edit,ar_timestamp,ar_user,ar_user_text,ar_comment
FROM archive WHERE ar_namespace={$namespace} AND ar_title=\"{$title}\"
ORDER BY ar_timestamp DESC";
- $ret = wfQuery( $sql );
+ $ret = wfQuery( $sql, DB_READ );
$special = $wgLang->getNsText( Namespace::getSpecial() );
$wgOut->addHTML("<ul>");
# Move article and history from the "archive" table
$sql = "SELECT COUNT(*) AS count FROM cur WHERE cur_namespace={$namespace} AND cur_title='{$t}'";
- $res = wfQuery( $sql );
+ $res = wfQuery( $sql, DB_READ );
$row = wfFetchObject( $res );
if( $row->count == 0) {
# Have to create new article...
"SELECT ar_namespace,ar_title,ar_text,ar_comment," .
"ar_user,ar_user_text,ar_timestamp,99999999999999-ar_timestamp,ar_minor_edit,RAND(),'{$now}' FROM archive " .
"WHERE ar_namespace={$namespace} AND ar_title='{$t}' AND ar_timestamp={$max}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
$newid = wfInsertId();
$oldones = "AND ar_timestamp<{$max}";
} else {
"old_flags) SELECT ar_namespace,ar_title,ar_text,ar_comment," .
"ar_user,ar_user_text,ar_timestamp,99999999999999-ar_timestamp,ar_minor_edit,ar_flags " .
"FROM archive WHERE ar_namespace={$namespace} AND ar_title='{$t}' {$oldones}";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# Finally, clean up the link tables
if( $newid ) {
$dummyOut = new OutputPage();
$to = Title::newFromDBKey( $target );
$res = wfQuery( "SELECT cur_text FROM cur WHERE cur_id={$newid} " .
- "AND cur_namespace={$namespace}", $fname );
+ "AND cur_namespace={$namespace}", DB_READ, $fname );
$row = wfFetchObject( $res );
$text = $row->cur_text;
$dummyOut->addWikiText( $text );
# Now that it's safely stored, take it out of the archive
$sql = "DELETE FROM archive WHERE ar_namespace={$namespace} AND " .
"ar_title='{$t}'";
- wfQuery( $sql, $fname );
+ wfQuery( $sql, DB_WRITE, $fname );
# Touch the log?
$sql = "SELECT img_name,img_user,img_user_text,img_timestamp,img_description " .
"FROM image LEFT JOIN imagelinks ON img_name=il_to WHERE il_to IS NULL " .
"ORDER BY img_timestamp LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$sk = $wgUser->getSkin();
$sql = "SELECT bl_to, COUNT( DISTINCT bl_from ) as nlinks " .
"FROM brokenlinks GROUP BY bl_to HAVING nlinks > 1 " .
"ORDER BY nlinks DESC LIMIT {$offset}, {$limit}";
- $res = wfQuery( $sql, $fname );
+ $res = wfQuery( $sql, DB_READ, $fname );
$sk = $wgUser->getSkin();